<script setup lang="ts">
import { computed, ref,  } from 'vue' //ref基本类型 resxxx引用类型
import { useStore } from '../store';  //
const store = useStore();
// defineProps<{ msg: string }>()
const count = ref(0)
const showCount = computed(()=>{      //vue3生命周期 及 监听计算等需这么用
  return store.getters['getCount'];
});
const addBtn = ()=>{
  store.commit('setCount',++count.value)
}
</script>

<template>
  <h1>
    <!-- store: {{$store.state.num}} -->
    <!-- {{ msg }} -->
    {{showCount}}
  </h1>
  <button type="button" @click="addBtn">新增++</button>
  <!-- <button type="button" @click="count++">count is: {{ count }}</button> -->
</template>

<style scoped>
a {
  color: #42b983;
}

label {
  margin: 0 0.5em;
  font-weight: bold;
}

code {
  background-color: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  color: #304455;
}
</style>
